<template>
    <div>
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-fl">部门设置</div>
                </div>
                <!-- <div class="am-u-sm-12 am-u-md-12 am-u-lg-3 am-form-group am-text-left g-bth">
                    <button  @click="$router.push('/main/crm/department/add')" type="button" class="btn-search am-btn am-btn-default am-btn-success">
                        <span class="am-icon-plus"></span>&nbsp;新建
                    </button>
                </div> -->
                <div class="am-u-sm-12 g-table-area">
                    <el-table
                    :data="tableData"
                    border
                    maxHeight="600"
                    empty-text="暂无数据"
                    stripe
                    style="min-width: 100%">
                    <el-table-column
                        min-width="100"
                        prop="name"
                        label="区域">
                    </el-table-column>
                    <el-table-column
                        label="操作"
                        min-width="100">
                        <template scope = "scope">
                             <el-button  @click="handEdit(scope.row)">编辑</el-button>
                        </template>
                    </el-table-column>
                    </el-table>
                </div>
                <div class="am-u-lg-12 am-cf">
                <div class="am-fr">
                    <pagination v-bind:total="total" v-bind:pageNo="pageNo" v-bind:pageSize="pageSize"
                                @paging="areaTeamList"/>
                </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import Pagination from '../base/Pagination'
import io from '../../lib/io'
export default {
    name:"department",
    components:{
        Pagination
    },
    data(){
        return{
            tableData:[],
            total:0,
            pageNo:1,
            pageSize:10,
        }
    },
    created(){
        this.areaTeamList()
    },
    methods:{
        handEdit(row){
            this.$router.push('/main/crm/department/add?areaTeamId=' + row.areaTeamId)
        },
        areaTeamList(pageNo){
             this.pageNo = pageNo || this.pageNo || 1
            let param = {
                pageNo:this.pageNo,
                pageSize:this.pageSize,
            }
            io.post(io.apiAdminAreaTeamList,param,(ret)=>{
                if(ret.success){
                    this.total = ret.data.total
                    this.tableData = ret.data.list
                }else{
                    this.$alert(ret.desc)
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
    .g-bth{
        padding:10px 0 0 15px;
    }
    .g-table-area{
        padding-left:15px;
        padding-top:20px;
    }
</style>

